//
//  MyAssetHeaderView.m
//  PigMarket
//
//  Created by mac on 2019/5/24.
//  Copyright © 2019 felix.pigmarket.oc. All rights reserved.
//

#import "MyAssetHeaderView.h"

@interface MyAssetHeaderView ()
/**
 bgView
 */
@property (nonatomic , strong) UIImageView *bgImg;
/**
 余额title
 */
@property (nonatomic , strong) UILabel *balanceTitle;
/**
 竖线
 */
@property (nonatomic , strong) UIView *sLine;
@end
@implementation MyAssetHeaderView

#pragma mark - init method
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self initView];
        [self initLayout];
    }
    return self;
}

- (void)initView {
    // 添加子控件
    [self addSubview:self.bgImg];
    [self.bgImg addSubview:self.balanceTitle];
    [self.bgImg addSubview:self.balance];
    [self.bgImg addSubview:self.sLine];
    [self.bgImg addSubview:self.withdrawBtn];
    [self.bgImg addSubview:self.topUpBtn];
}

- (void)initLayout {
    CGFloat screenScale = [JTool getScreenWidthScale];
    
    // 布局子控件
    [self.bgImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.right.bottom.mas_equalTo(0);
    }];
    [self.balanceTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.mas_centerX);
        make.centerY.mas_equalTo(self.bgImg.mas_centerY).offset(0);
        make.height.mas_equalTo(18);
    }];
    [self.balance mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.mas_centerX);
        make.top.mas_equalTo(self.balanceTitle.mas_bottom).offset(1 * screenScale);
        make.height.mas_equalTo(42);
    }];
    [self.sLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.mas_centerX);
        make.top.mas_equalTo(self.balance.mas_bottom).offset(17 * screenScale);
        make.size.mas_equalTo(CGSizeMake(1, 12));
    }];
    [self.withdrawBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.sLine.mas_centerY);
        make.right.mas_equalTo(self.sLine.mas_left).offset(-20);
        make.height.mas_equalTo(21);
    }];
    [self.topUpBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.sLine.mas_centerY);
        make.left.mas_equalTo(self.sLine.mas_right).offset(20);
        make.height.mas_equalTo(21);
    }];
}

#pragma mark - getter and setter
- (UIImageView *)bgImg {
    if (!_bgImg) {
        _bgImg = [[UIImageView alloc] init];
        _bgImg.image = [UIImage imageNamed:@"meat_buy_bg"];
        _bgImg.userInteractionEnabled = YES;
    }
    return _bgImg;
}
- (UILabel *)balanceTitle {
    if (!_balanceTitle) {
        _balanceTitle = [[UILabel alloc] init];
        _balanceTitle.textColor = [UIColor whiteColor];
        _balanceTitle.font = [UIFont systemFontOfSize:13];
        _balanceTitle.text = @"(余额)";
    }
    return _balanceTitle;
}
- (UILabel *)balance {
    if (!_balance) {
        _balance = [[UILabel alloc] init];
        _balance.textColor = [UIColor whiteColor];
        _balance.font = [UIFont boldSystemFontOfSize:30];
    }
    return _balance;
}
- (UIView *)sLine {
    if (!_sLine) {
        _sLine = [[UIView alloc] init];
        _sLine.backgroundColor = [UIColor colorWithHexString:@"#009E18"];
    }
    return _sLine;
}
- (UIButton *)withdrawBtn {
    if (!_withdrawBtn) {
        _withdrawBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_withdrawBtn setTitle:@"提现" forState:UIControlStateNormal];
        [_withdrawBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        _withdrawBtn.titleLabel.font = [UIFont systemFontOfSize:15];
    }
    return _withdrawBtn;
}
- (UIButton *)topUpBtn {
    if (!_topUpBtn) {
        _topUpBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_topUpBtn setTitle:@"充值" forState:UIControlStateNormal];
        [_topUpBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        _topUpBtn.titleLabel.font = [UIFont systemFontOfSize:15];
    }
    return _topUpBtn;
}
@end
